/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii
   @Language: C++
   @Datetime: 19-08-23 14:54
   */

class Solution {
public:
	int maxProfit(vector<int>& prices) {
		int p=0;
		for(int i=1; i<prices.size(); ++i)
			p += max(0,prices[i]-prices[i-1]);
		return p;
	}
};
